package com.lanlengran.hotupdatetest;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.TextView;

public class SplashActivity extends AppCompatActivity {

    private TextView textview;
    private  Handler handler;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        textview=findViewById(R.id.textview);

        handler=new Handler(msg -> {
            textview.setText(msg.arg1+"秒");
            if (msg.arg1>0){
                Message newMsg=new Message();
                newMsg.arg1=msg.arg1-1;
                handler.sendMessageDelayed(newMsg,1000);
            }else {
                startActivity(new Intent(SplashActivity.this,MainActivity.class));
                finish();
            }
            return false;
        });
        Message msg=new Message();
        msg.arg1=5;
        handler.sendMessage(msg);

    }
}